//
//  XMFriendListCell.m
//  XMJJ_zmy
//
//  Created by 丁浩 on 2025/7/7.
//

#import "XMFriendListCell.h"


@interface XMFriendListCell ()

@property (nonatomic, strong) UIImageView *avatarImgView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *introLabel;

@end

@implementation XMFriendListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style
              reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatUI];
    }
    return self;
}

- (void)creatUI {
    [self addSubview:self.avatarImgView];
    [self addSubview:self.nameLabel];
    [self addSubview:self.introLabel];
}

- (void)setContentWithFriendModel:(XMFriendModel *)friendModel {
    if (friendModel.avatar && friendModel.avatar.length > 0) {
        [_avatarImgView sd_setImageWithURL:[NSURL URLWithString:friendModel.avatar]];
    }
//    _avatarImgView.image = [UIImage imageWithColor:kColorHEX(0x00ffff)];
    _nameLabel.text = friendModel.nickname;//@"王五一";
    _introLabel.text = friendModel.dsc;//@"用户简介用户简介";
}

#pragma mark - Init
- (UIImageView *)avatarImgView {
    if (!_avatarImgView) {
        _avatarImgView = [[UIImageView alloc] initWithFrame:CGRectMake(KScaleWidth(16.0), KScaleWidth(16.0), KScaleWidth(46.0), KScaleWidth(46.0))];
        _avatarImgView.image = ImageNamed(@"mine_avatar_icon");
        [_avatarImgView setCornerRadius:_avatarImgView.height/2];
        _avatarImgView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _avatarImgView;
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(KScaleWidth(75.0), KScaleWidth(15.0), kScreenWidth, KScaleWidth(25.0)) font:KBoldFontSize(15.0) textColor:kColorHEX(0x333333)];
    }
    return _nameLabel;
}

- (UILabel *)introLabel {
    if (!_introLabel) {
        _introLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.nameLabel.x, _nameLabel.maxY, _nameLabel.width, KScaleWidth(26.0)) font:KFontSize(14.0) textColor:kColorHEX(0x999999)];
    }
    return _introLabel;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
